package cn.monkey.data.mongo;

import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.repository.query.MongoEntityInformation;
import org.springframework.data.mongodb.repository.support.SimpleMongoRepository;

public class SimpleMongoCrudRepository<T, ID> extends SimpleMongoRepository<T, ID> implements MongoCrudRepository<T, ID> {

    protected final MongoEntityInformation<T, ID> entityInformation;

    protected final MongoOperations mongoOperations;
    protected MongoRepositoryBehaviorContext<T> mongoRepositoryBehaviorContext;

    /**
     * Creates a new {@link SimpleMongoRepository} for the given {@link MongoEntityInformation} and {@link MongoOperations}.
     *
     * @param metadata        must not be {@literal null}.
     * @param mongoOperations must not be {@literal null}.
     */
    public SimpleMongoCrudRepository(MongoEntityInformation<T, ID> metadata, MongoOperations mongoOperations) {
        super(metadata, mongoOperations);
        this.mongoOperations = mongoOperations;
        this.entityInformation = metadata;
    }

    public void setMongoRepositoryBehaviorContext(MongoRepositoryBehaviorContext<T> mongoRepositoryBehaviorContext) {
        this.mongoRepositoryBehaviorContext = mongoRepositoryBehaviorContext;
    }

    @Override
    public MongoRepositoryBehaviorContext<T> getMongoRepositoryContext() {
        return this.mongoRepositoryBehaviorContext;
    }

    @Override
    public MongoEntityInformation<T, ID> getEntityInformation() {
        return this.entityInformation;
    }


    @Override
    public MongoOperations getMongoOperations() {
        return this.mongoOperations;
    }

}
